package com.lachesis.molecule.web.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/** 
 * @ClassName: CrossDomainInterceptor 
 * @Description: 跨域拦截器，向HTTP Header中添加跨域信息 
 * @author shiwei.hu shiwei.hu@lachesis-mh.com
 * @date 2017年10月31日 下午7:19:02 
 *  
 */
class CrossDomainInterceptor extends HandlerInterceptorAdapter{
    
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        
        response.addHeader("Access-Control-Allow-Origin","*");
        response.addHeader("Access-Control-Allow-Methods","GET,POST,PUT,DELETE,PATCH");
        response.addHeader("Access-Control-Allow-Headers", "Authorization");
        return super.preHandle(request, response, handler);
    }
}
